/************************************************************************/
/*    author  vinee.han
/*    time    2015/06/05
/*    wikioi                                                 
/************************************************************************/

#include <iostream>
using namespace std;

int cnt = 1;

void hanoi(int n,char a,char b,char c)
{
	if(n>=1)
	{
        hanoi(n-1,a,c,b);
		cout<<n<<" from "<<a<<" to "<<c<<endl;
		hanoi(n-1,b,a,c);
	}
}

int main()
{
	int n;
	cin>>n;
	for (int i = 1;i <= n;i++)
	{
		cnt*=2;
	}
	cout<<cnt-1<<endl;
	hanoi(n,'A','B','C');
	return 0;
}